package com.zhida.userservice.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.zhida.common.entity.Result;



import com.zhida.userservice.entity.User;
import com.zhida.userservice.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Your Name
 * @since 2024-07-15
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    IUserService userService;

    @PostMapping("/login")
    public Result<?> login(@RequestBody User user){
        return userService.login(user);
    }

    @PostMapping("/register")
    public Result<?> register(@RequestBody User user){
        return userService.register(user);
    }

    @PostMapping("/updateUserInfo")
    public Result<?> updateUserInfo(@RequestBody User user){
        return userService.updateUserInfo(user);
    }

    @PostMapping("/getUserInfo")
    public Result<?> getUserInfo() throws JsonProcessingException {
        return userService.getUserInfo();
    }
}
